cmake_minimum_required(VERSION 3.17)
project(c-cpp C)

set(CMAKE_C_STANDARD 99)
if (MSVC)
    set(CMAKE_C_FLAGS "/utf-8")
endif ()

message("CMAKE_C_COMPILER is ${CMAKE_C_COMPILER}")
message("CMAKE_C_COMPILER_ID is ${CMAKE_C_COMPILER_ID}")
message("Current Platform name is [${CMAKE_SYSTEM}]-[${CMAKE_SYSTEM_NAME}]")
if (CMAKE_HOST_UNIX)
    message(CMAKE_HOST_UNIX)
endif ()
if (CMAKE_HOST_APPLE)
    message(CMAKE_HOST_APPLE)
endif ()
if (UNIX AND NOT APPLE)
    message(LINUX)
endif ()
if (CMAKE_HOST_WIN32)
    message(CMAKE_HOST_WIN32)
endif ()

if (UNIX AND NOT APPLE)
    find_package(Threads REQUIRED)
endif ()

include_directories("tinycthread/include")
add_executable(${PROJECT_NAME} main.c tinycthread/tinycthread.c)

if (UNIX AND NOT APPLE)
    target_link_libraries(${PROJECT_NAME} Threads::Threads)
endif ()
